/**
 * 
 */
package ipc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.concurrent.ArrayBlockingQueue;

import mdp.solve.DifferenceDisplayer;

import util.Pair;

import dd.discrete.ADD;
import dd.discrete.DD;

/**
 * @author NR
 *
 * TODO
 */
public class TestDiffDisp {
	public static void main(String[] args) throws Exception {
		ArrayList ord1 = new ArrayList();
		ord1.add("X");
		ord1.add("Y");
		
		ArrayList ord2 = new ArrayList();
		ord2.add("Y");
		ord2.add("X");
		
		TreeMap<String, Boolean> assign1 = new TreeMap<String, Boolean>();
		assign1.put("A1", true);

		TreeMap<String, Boolean> assign2 = new TreeMap<String, Boolean>();
		assign2.put("A2", true);
		
		TreeMap<String, Boolean> assign0 = new TreeMap<String, Boolean>();
		assign0.put("A3", true);
		
		HashMap<Long, TreeMap<String, Boolean>> leafmap1 = new HashMap<Long, TreeMap<String, Boolean>>();
		leafmap1.put(1L, assign1 );
		leafmap1.put(2L, assign2);
		leafmap1.put(0L, assign0);
		
		HashMap<Long, TreeMap<String, Boolean>> leafmap2 = new HashMap<Long, TreeMap<String, Boolean>>();
		leafmap2.put(2L, assign1 );
		leafmap2.put(4L, assign2);
		leafmap2.put(0L, assign0);
		
		ADD context1 = new ADD(ord1);
		int x = context1.getVarNode("X", 0.0, 1);
		int y = context1.getVarNode("Y", 1.0, 0);
		int dd1 = context1.applyInt(x,y,DD.ARITH_SUM);
		
		ADD context2 = new ADD(ord2);
		x = context2.getVarNode("X", 0.0, 2);
		y = context2.getVarNode("Y", 2.0, 0);
		int dd2 = context2.applyInt(x,y,DD.ARITH_SUM);
		
		ArrayBlockingQueue<Pair<ADD, Pair<Integer, HashMap<Long, TreeMap<String, Boolean>>>>> 
			pBq2 = new ArrayBlockingQueue<Pair<ADD,Pair<Integer,HashMap<Long,TreeMap<String,Boolean>>>>>(1);
		ArrayBlockingQueue<Pair<ADD, Pair<Integer, HashMap<Long, TreeMap<String, Boolean>>>>> 
			pBq1 = new ArrayBlockingQueue<Pair<ADD,Pair<Integer,HashMap<Long,TreeMap<String,Boolean>>>>>(1);
		
		DifferenceDisplayer disp = new DifferenceDisplayer(pBq1, pBq2);
		Thread diffWorker = new Thread(disp, "differ");
		diffWorker.start();
		
		pBq1.put(new Pair<ADD, Pair<Integer,HashMap<Long,TreeMap<String,Boolean>>>>(context1,
				        new Pair<Integer, HashMap<Long, TreeMap<String, Boolean>>>(dd1, leafmap1)));
		
		pBq2.put(new Pair<ADD, Pair<Integer,HashMap<Long,TreeMap<String,Boolean>>>>(context2,
		        new Pair<Integer, HashMap<Long, TreeMap<String, Boolean>>>(dd2, leafmap2)));
	}
}
